$NG.AllReady(function (page, { useDataIndexChange, useValuesChange, useUpdateRows }) {
    const mstform = $NG.getCmpApi("p_form_visa_data_m");
    //项目名称变化时自动带入产品线、事业部等
    useValuesChange(({ args }) => {
        console.log(args[0]);
        //const phid_pc = args[0].pc.PhId;
        const phid_pc = args[0].phid_pc.value;
        //从项目取值
        if (phid_pc) {
            console.log(phid_pc);
            //从项目取值
            $NG.execServer("GetCbCntInfo", { pc: phid_pc }, function (res) {
                const data = JSON.parse(res.data);
                const htbh = data[0].extendObjects.htbh;
                const htqdrq = data[0].extendObjects.htqdrq;
                const zbrq = data[0].extendObjects.zbrq;
                const kgrq = data[0].extendObjects.kgrq;
                const wgrq = data[0].extendObjects.wgrq;
                //const glzz = data[0].extendObjects.glzz;
                //const glzz_name = data[0].extendObjects.glzz_name;
                //开工日期、完工日期、中标日期、合同签订日期
                $NG.updateState((updater) => {
                    updater.data.p_form_visa_data_m.setProps({
                        u_cnt_no: htbh,
                        u_htqd_dt: htqdrq,
                        u_start_dt: kgrq,
                        u_end_dt: wgrq,
                        u_zb_dt: zbrq,
                       /* u_org: {
                            //帮助需要赋两个值value、label
                            value: glzz,
                            label: glzz_name,
                        } */
                    });
                });
            });
        }
        setTitle()

    }, "p_form_visa_data_m.phid_pc");
    setTitle()
    function setTitle(){
        $NG.execServer("GetVisaTime",{phid_pc:mstform.getItem("phid_pc").getValue()},function(res){
            console.log(res);
            if(res.count ==0){
                $NG.updateState((updater)=>{
                    updater.data.p_form_visa_data_m.setProps({
                        u_zt:`${mstform.getItem("phid_pc").getText()}第1次签证`
                    })
                })
            }else{
                const _data = JSON.parse(res.data)[0].extendObjects
                $NG.updateState((updater)=>{
                    updater.data.p_form_visa_data_m.setProps({
                        u_zt:`${mstform.getItem("phid_pc").getText()}第${(_data.count)+1}次签证`
                    })
                })
            }
            
        })
    }
});
